import { View, Image, Text } from '@tarojs/components';
import { AtIcon } from 'taro-ui';
import selectBg from '@/assets/images/shop/select_bg.png';
import selectIcon from '@/assets/images/shop/select.png';
import './index.scss';

export default function ({ shop, onChange, isSelected, type }) {
  const _onChange = () => {
    onChange?.(shop);
  };

  return (
    <View className="shop-array-item" onClick={_onChange}>
      {isSelected && type === 'edit' && (
        <View className="select-content">
          <Image className="select-bg" src={selectBg} />
          <Image className="select-icon" src={selectIcon} />
        </View>
      )}
      <View className="shop-info">
        <View className="shop-image">
          <Image src={shop.logo} />
        </View>
        <View className="shop-right">
          <View className="shop-name">{shop.store_name}</View>
          <View className="shop-address">
            <AtIcon value="map-pin" size="18" color="#333333" />
            <Text className="address-text">{shop.store_address}</Text>
            {shop.distance !== 0 && (
              <Text>
                {shop.distance > 1000
                  ? `${Math.round(shop.distance / 1000)}km`
                  : `${shop.distance}m`}
              </Text>
            )}
          </View>
          <View className="shop-status">
            <AtIcon value="clock" size="16" color="#333333" />
            {/* {shop.is_open === 1 ? (
              <AtTag circle className="red-color" size="small">
                营业中
              </AtTag>
            ) : (
              <AtTag circle size="small">
                休息中
              </AtTag>
            )} */}
            <Text>{shop.shop_hours}</Text>
          </View>
          {/* <View className="shop-bottom">
            <View className="shop-vip">{shop.member_count}个会员选择</View>
            <View className="shop-level">
              <AtRate size={15} max={shop.level} value={shop.level} />
            </View>
          </View> */}
        </View>
      </View>
    </View>
  );
}
